package com.fzf.org.anno.validator;

import com.fzf.org.anno.MyPhone;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class MyPhoneValidator implements ConstraintValidator<MyPhone, String> {
    private static final String REGEX = "^1[3-9]\\d{9}$";

    @Override
    public boolean isValid(String phone, ConstraintValidatorContext constraintValidatorContext) {
        return null == phone || phone.matches(REGEX);
    }
}